package com.swagger.demo.admin;

import java.io.File;

import com.jfinal.core.Controller;
import com.jfinal.core.Path;
import com.jfinal.upload.UploadFile;
import com.lastb7.swagger.enumeration.ApiEnum;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @author: lbq
 * @email: 526509994@qq.com
 * @date: 2022/6/24
 */
@Path("/file")
@Api(tags = "附件上传")
public class FileController extends Controller {

    @ApiOperation(value = "新建个人签名", consumes = ApiEnum.CONSUMES_FORM_DATA, httpMethod = ApiEnum.METHOD_POST)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "form", dataType = "file", name = "file", value = "签名图片", required = false),
    })
    public void test1() {

        UploadFile file = this.getFile();

        this.renderText(file.getFileName());
    }

    @ApiOperation(value = "文件下载", produces = ApiEnum.PRODUCES_PNG)
    public void download() {

        this.renderFile(new File("/Users/lbq/Desktop/1.png"));

    }
}
